bitmask: Optimize intersect
authorMatthias Clasen <mclasen@redhat.com>
Thu, 10 Sep 2015 22:46:58 +0000 (18:46 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 12 Sep 2015 15:24:37 +0000 (11:24 -0400)
The functions was written in a way that would possibly
resize the mask twice, which is not necessary.

gtk/gtkallocatedbitmask.c

index 6f0f1f86163a2a7759033723d44f09c4f1dec230..567b86cb91b65551a5e2b7a93d14265475c658a0 100644 (file)
@@ -174,11 +174,14 @@ _gtk_allocated_bitmask_intersect (GtkBitmask       *mask,
   mask = gtk_bitmask_ensure_allocated (mask);
   ENSURE_ALLOCATED (other, other_allocated);
 
-  mask = gtk_allocated_bitmask_resize (mask, MIN (mask->len, other->len));
-  for (i = 0; i < mask->len; i++)
+  for (i = 0; i < MIN (mask->len, other->len); i++)
     {
       mask->data[i] &= other->data[i];
     }
+  for (; i < mask->len; i++)
+    {
+      mask->data[i] = 0;
+    }
 
   return gtk_allocated_bitmask_shrink (mask);
 }